<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ajax_lib" tagdir="/WEB-INF/tags/ajax" %>

<%@ attribute name="modelAttribute" required="true" rtexprvalue="true" %>
<%@ attribute name="id" required="true" rtexprvalue="true" %>
<%@ attribute name="formUrl" required="true" rtexprvalue="true" description="the .htm extension is added"%>
<%@ attribute name="ajax" required="false" rtexprvalue="true" description="validate the form using ajax. The URL is \${formUrl}.ajax"%>

<spring:url value="${formUrl}" var="processedFormUrl" />
<form:form modelAttribute="${modelAttribute}" id="${id}" action="${processedFormUrl}.htm" class="form-horizontal">
	<fieldset>
       <jsp:doBody />
    </fieldset>
</form:form>

<c:if test="${ajax}">
	<ajax_lib:formWithValidation validateUrl="${processedFormUrl}.json" formName="${id}"/>
</c:if>